<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class Wait {
	
	public function __construct() {
		$this->id = 505;
		$this->name = "待机";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid]);
	}
	
	//行动函数
	public function action($a){
		if($a->cid == 141) {
			$_SESSION['show'] .= "哼，先放过汝一次。<br>";
			CalHelper::cgdisplay('guiwood_def.jpg');
		}
		$_SESSION['show'] .= $a->name."呆呆地傻站着（HP/SP/AP回复）";
		$a->hp = ($a->hp + 40 > $a->mxhp) ? $a->mxhp : ($a->hp + 40);
		$a->sp = ($a->sp + 20 > $a->mxsp) ? $a->mxsp : ($a->sp + 20);
		$a->ap = CalHelper::apointchange($a->ap,-1);
	}
	
}

class Defence {
	
	public function __construct() {
		$this->id = 505;
		$this->name = "防御";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 2;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid]);
		CalHelper::cost_cal($a[$atkid],$this);
	}
	//行动函数
	public function action($a){
		if($a->ap < 5) {
			$_SESSION['show'] .= $a->name." AP 不足，连防御的力气也没有了……<br>";
			return 0;
		}
		if($a->cid == 141) {
			$_SESSION['show'] .= "哼，现在必须忍耐。<br>";
			CalHelper::cgdisplay('guiwood_def.jpg');
		}
		if($a->cid == 1) {
			$_SESSION['show'] .= "就用这宝座，构筑我坚实的结界吧。<br>";
			CalHelper::cgdisplay('teaplum_12.jpg');
		}
		$_SESSION['show'] .= $a->name."龟缩起来，进入防御状态。<br>";
		$a->before_status[2]->on = 1;
		$a->defskill_status[3]->on =1;
	}
	
}

class PullUp {
	
	public function __construct() {
		$this->id = 386;
		$this->name = "拉起队友";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}
	//行动函数
	public function action($a,$b){
		$_SESSION['show'] .= $a->name."把".$b->name."拉了起来。<br>";
		$b->before_status[0]->cancel($b);
		$b->defskill_status[0]->cancel($b);
	}
	
}

class SkipAction {
	
	public function __construct() {
		$this->id = 387;
		$this->name = "跳过行动";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid]);
	}

	//行动函数
	public function action($a){
		$_SESSION['show'] .= $a->name."跳过了行动。<br>";
	}
	
}

class MoonGrass {
	
	public function __construct() {
		$this->id = 508;
		$this->name = "月草";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}

	public function action($a,$b){
		$_SESSION['show'] .= $a->name."为".$b->name."灌下".$this->name."，AP增加<br>";
		$b->ap = CalHelper::apointchange($b->ap,6);
		$a->ap = CalHelper::apointchange($a->ap,-2);
	}
	
}

class HellSoup {
	
	public function __construct() {
		$this->id = 509;
		$this->name = "般若湯";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}

	public function action($a,$b){
		$_SESSION['show'] .= $a->name."为".$b->name."灌下".$this->name."，SP增加<br>";
		$b->sp += 150;
		if($b->sp > $b->mxsp) $b->sp = $b->mxsp;
		$a->ap = CalHelper::apointchange($a->ap,-2);
	}
	
}

class TusuWine {
	
	public function __construct() {
		$this->id = 510;
		$this->name = "屠蘇";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}

	public function action($a,$b){
		$_SESSION['show'] .= $a->name."为".$b->name."灌下".$this->name."，HP增加<br>";
		$b->hp += 400;
		if($b->hp > $b->mxhp) $b->hp = $b->mxhp;
		$a->ap = CalHelper::apointchange($a->ap,-2);
	}
	
}

class GangesWater {
	
	public function __construct() {
		$this->id = 512;
		$this->name = "恒河水";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		$this->v = 25;
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}

	//行动函数
	public function action($a,$b){
		if($a->cid == 120) {
			$_SESSION['show'] .= $a->name."：“战术，只是战略的一部分。”<br>";
		}
		$_SESSION['show'] .= $a->name."为".$b->name."灌下".$this->name."<br>";
		if($b->before_status[48]->on == 1) {
			$_SESSION['show'] .= $b->name."肚子撑得呕吐了起来，幸好什么也没发生...<br>";
		} elseif($b->hp > floor($b->mxhp/2)) {
			$_SESSION['show'] .= $b->name."吐得连".$a->name."身上都到处是异味浓厚的水，可惜什么也没发生...<br>";
		} else {
			$b->str += $this->v;
			$b->mgr += $this->v;
			$b->spd += $this->v;
			$b->vit += $this->v;
			$b->before_status[48]->on = 1;
			$b->before_status[48]->v = $this->v;
			$b->hp = floor($b->hp * 0.4);
			if($b->hp <= 0) $b->hp = 1;
			$a->ap = CalHelper::apointchange($a->hp,-2);
			$b->sap = CalHelper::apointchange($b->sap,-2);
			$_SESSION['show'] .= $b->name."面色发黑，身体着了魔般地兴奋了起来，全能力大大上升(剩余3回合)<br>";
		}
	}
	
}

class PassiveReset {

	public function __construct() {
		$this->id = 513;
		$this->name = "重置自身被动技能";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		$this->sysop = 1;
		
	}
	
	public function start($a,$b) {
		$this->action($a);
	}

	//行动函数
	public function action($a){

		//事件数组全部是被动
		foreach($a->eventskill_status as $as) {
			if($as->on == 1){
				$as->cancel($a);
			}
		}

		//事前被动数组
		$befarray = array(1,62,63,64,65,66,67);
		foreach($befarray as $ba) {
			if($a->before_status[$ba]->on == 1) {
				$a->before_status[$ba]->cancel($a);
			}
		}

		//攻击被动数组
		$atkarray = array(1,8,13,16,17,18,19,20,22,23,24,25,27,37,38,39,42,43,44,45,46,47,48,49,50);
		foreach($atkarray as $ak) {
			if($a->atkskill_status[$ak]->on == 1) {
				$a->atkskill_status[$ak]->cancel($a);
			}
		}

		//防御被动数组
		$defarray = array(12,13,15,16,17,18,19,20,21);
		foreach($defarray as $de) {
			if($a->defskill_status[$de]->on == 1) {
				$a->defskill_status[$de]->cancel($a);
			}
		}
		
		//攻击后置被动数组
		$akfarray = array(1,2);
		foreach($akfarray as $af) {
			if($a->atkafter_status[$af]->on == 1) {
				$a->atkafter_status[$af]->cancel($a);
			}
		}

		//防御后置被动数组
		$dafarray = array(1,2,4);
		foreach($dafarray as $df) {
			if($a->defafter_status[$df]->on == 1) {
				$a->defafter_status[$df]->cancel($a);
			}
		}
		$_SESSION['show'] .= $a->name."的全部被动技能已被取消。<br>";
	}

}

class GoTurn {
	
	public function __construct() {
		$this->id = 513;
		$this->name = "跳过回合";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		$this->sysop = 1;
		
	}
	
	public function start($a,$b) {
		$this->action();
	}

	//行动函数
	public function action(){
		CalHelper::go_turn(1);
		$_SESSION['show'] .= "回合已前进。<br>";
	}
	
}

class Escape {
	
	public function __construct() {
		$this->id = 514;
		$this->name = "撤退";			//技能名称
		$this->type = 20;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 6;
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		CalHelper::cost_cal($a[$atkid],$this);
		$this->action($a[$atkid]);
	}

	public function action($a){
		$tmp = mt_rand(1,100);
		$_SESSION['result'] .= "撤退乱数：.$tmp<br>";
		if($a->eventskill_status[17]->on == 1) $a->eodds += 10;
		if($a->before_status[46]->on == 1) $a->eodds += 30;
		if($a->eodds >= $tmp) {
			$_SESSION['show'] .= $a->name."不顾还在浴血奋战的队友，一溜烟逃跑了<br>";
			StatusHelper::escape($a);
		} else {
			$_SESSION['show'] .= $a->name."撤退失败，被愤怒的队友狠狠拽了回来，陷入了深深的恐惧中<br>";
			StatusHelper::terror($a,$a,-100,$this);
		}
	}
	
}

class ForceDown {

	public function __construct() {
		$this->id = 586;
		$this->name = "强制倒地";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		$this->sysop = 1;
		
	}
	
	public function start($a,$b) {
		$this->action($a,$b);
	}

	//行动函数
	public function action($a,$b){
		//一切常规异常被取消
		StatusHelper::cure_mentalspt($b);	
		StatusHelper::cure_bodyspt($b);	

		$b->before_status[0]->on = 1;
		$b->defskill_status[0]->on = 1;
		//防御取消
		$b->before_status[2]->cancel($b);
		$b->defskill_status[3]->cancel($b);

	}

}


class KuXin {
	
	public function __construct() {
		$this->id = 531;
		$this->name = "苦辛";			//技能名称
		$this->type = 15;			//组别
	
		$this->hp = 0;			//消耗
		$this->sp = 0;
		$this->ap = 0;
		
	}
	
	public function start($a,$b,$atkid,$defid,$defer) {
		$this->action($a[$atkid],$defer);
	}

	public function action($a,$b){
		if($a->cid == 120) {
			$_SESSION['show'] .= $a->name."：“战术，只是战略的一部分。”<br>";
		}
		if($b->before_status[49]->on == 1) {
			$_SESSION['show'] .= $b->name."的苦胆汁倒灌了出来，吐得稀里哗啦的，然后什么也没发生。<br>";
			return 0;
		} else {
			$_SESSION['show'] .= $a->name."为".$b->name."灌下".$this->name."，SAP增加<br>";
			$b->sap = CalHelper::apointchange($b->sap,7);
			$a->ap = CalHelper::apointchange($a->ap,-2);
			$b->before_status[49]->on = 1;
			if($b->str < 30) {
				$b->before_status[49]->vs = $b->str;
				$b->str = 0;
			} else {
				$b->before_status[49]->vs = 30;
				$b->str -= 30;
			}
			if($b->mgr < 30) {
				$b->before_status[49]->vm = $b->mgr;
				$b->mgr = 0;
			} else {
				$b->before_status[49]->vm = 30;
				$b->mgr -= 30;
			}
		}
	}
	
}

?>
